package com.ss.android.wenda.answer.list;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.a.a.NightMode;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.retrofit2.Callback;
import com.bytedance.retrofit2.ResponseWrapper;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.detail2.widget.DetailTitleBar;
import com.ss.android.article.base.ui.NoDataViewFactory$ImgType;
import com.ss.android.article.base.ui.aa;
import com.ss.android.article.base.ui.ab;
import com.ss.android.article.base.ui.ac;
import com.ss.android.article.base.ui.ad;
import com.ss.android.article.base.ui.NoNetView;
import com.ss.android.article.base.utils.JSONObjectWrapper;
import com.ss.android.article.browser.R;
import com.ss.android.article.common.page.PageList;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.callback.SSCallback;
import com.ss.android.common.ui.view.SwipeOverlayFrameLayout;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.topic.d.a;
import com.ss.android.wenda.a.h;
import com.ss.android.wenda.model.Answer;
import com.ss.android.wenda.model.response.f;
import java.util.HashMap;
import java.util.Map;

public final class k extends a implements
        OnPageChangeListener,
        NightMode,
        Callback,
        DetailTitleBar.OnChildViewClickCallback,
        com.ss.android.wenda.model.Answer.Answer$a {
    private Activity k;
    private DetailTitleBar l;
    private SwipeOverlayFrameLayout m;
    private View n;
    private NoNetView o;
    private String p;
    private String q;
    private String r;
    private com.ss.android.wenda.a.a s;
    private SSCallback t;
    private boolean u;
    private SSCallback v;
    private SSCallback w;
    private View.OnClickListener x;

    public k() {

        this.u = false;
        this.v = new l(this);
        this.w = new m(this);
        this.x = new n(this);
    }

    public final void onBackClick() {
        this.getActivity().onBackPressed();
    }

    public final void onTopMoreTitleClick() {
    }

    public final void onCloseAllWebPageClick() {
    }

    public final void onWechatShareClick() {
    }

    public final void onQQShareClick() {
    }

    public final void onMomentShareClick() {
    }

    public final void onInfoBackClick() {
    }

    static com.ss.android.wenda.a.a a(k arg1) {
        return arg1.s;
    }

    private static void a(String arg1) {
        if(Logger.debug()) {
            Logger.d("FoldAnswerListFragment", arg1);
        }
    }

    public final void onPageScrollStateChanged(int state) {
    }

    public final void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    }

    public final void a(AbsListView arg4, int arg5, int arg6, int arg7) {
        super.a(arg4, arg5, arg6, arg7);
        String v0 = "loadmore_fold";
        if(!android.support.design.a.isTextEmpty(v0)) {
            MobClickCombiner.onEvent(this.getActivity(), "question", v0);
        }
    }

    public final void onCacheResponse(ResponseWrapper response) {
        if(response != null) {
            Object v0 = response.body;
            if(this.isViewValid()) {
                a("onResponse");
                PageList v1 = this.j();
                f v2 = new f();
                v2.a = ((com.ss.android.wenda.model.response.e)v0).a;
                v2.b = ((com.ss.android.wenda.model.response.e)v0).b;
                v2.e = ((com.ss.android.wenda.model.response.e)v0).e;
                v2.d = ((com.ss.android.wenda.model.response.e)v0).d;
                v2.c = ((com.ss.android.wenda.model.response.e)v0).c;
                v1.onLoadCompleted(v2);
                this.b();
                this.c();
            }
        }
    }

    public final void onErrorResponse(Throwable throwable) {
        if(this.isViewValid()) {
            this.d();
        }
    }

    static Activity b(k arg1) {
        return arg1.k;
    }

    public final void b() {
        UIUtils.setVisibility(this.o, 8);
    }

    public final void onPageSelected(int position) {
    }

    public final void d() {
        if(this.o == null) {
            this.o = android.support.design.a.a(this.getActivity(), this.n, ac.b(NoDataViewFactory$ImgType.NOT_NETWORK), ad.a(this.getString(com.ss.android.article.browser.R.string.not_network_tip)), ab.a(new aa(this.getString(com.ss.android.article.browser.R.string.label_retry), this.x)));
        }

        this.c();
        this.o.initNoDataActionBtn();
        this.o.setVisibility(View.VISIBLE);
    }

    public final void f() {
        a("refresh");
        this.e();
        HashMap v0 = new HashMap();
        ((Map)v0).put("qid", String.valueOf(this.p));
        if(!android.support.design.a.isTextEmpty(this.r)) {
            ((Map)v0).put("api_param", this.r);
        }

        ((Map)v0).put("gd_ext_json", k());
        new com.ss.android.wenda.a.g(((Map)v0), ((Callback)this)).e();
    }

    public final BaseAdapter g() {
        this.s = new com.ss.android.wenda.a.a(this.p, 2, this.q, this.r);
        this.registerLifeCycleMonitor(this.s);
        ((a)this).a.setRecyclerListener(this.s);
        return this.s;
    }

    public final PageList h() {
        return new h(this.p, this.r, k());
    }

    public final boolean i() {
        return false;
    }

    private static String k() {
        JSONObjectWrapper v0 = new JSONObjectWrapper();
        v0.put("enter_from", "click_answer_fold");
        return v0.jsonObject.toString();
    }

    public final void l() {
        this.s.notifyDataSetChanged();
    }

    public final void onAddressEditClicked(View arg1) {
    }

    public final void onCreate(Bundle bundle) {
        this.k = this.getActivity();
        Intent v0 = this.k.getIntent();
        if(v0 != null) {
            this.q = v0.getStringExtra("gd_ext_json");
            this.r = v0.getStringExtra("api_param");
            this.r = android.support.design.a.a(this.r, null, "question_fold");
            this.p = v0.getStringExtra("qid");
        }

        if(android.support.design.a.isTextEmpty(this.p)) {
            this.k.finish();
        }

        super.onCreate(bundle);
    }

    public final View onCreateView(LayoutInflater arg3, ViewGroup arg4, Bundle arg5) {
        this.n = super.onCreateView(arg3, arg4, arg5);
        com.ss.android.article.base.feature.detail2.config.a.b(this.n);
        com.ss.android.article.base.feature.detail2.config.a.b(((a)this).a);
        this.m = this.k.findViewById(com.ss.android.article.browser.R.id.fragment_container);
        android.support.design.a.a(this.getActivity(), this.m);
        Answer.registerListener(((com.ss.android.wenda.model.Answer.Answer$a)this));
        return this.n;
    }

    public final void onDestroy() {
        super.onDestroy();
        Answer.unregisterListener(((com.ss.android.wenda.model.Answer.Answer$a)this));
        CallbackCenter.removeCallback(BaseAppData.callbackTypeDeleteAnswer, this.t);
        CallbackCenter.removeCallback(BaseAppData.callbackTypeFontSizeChange, this.w);
        CallbackCenter.removeCallback(BaseAppData.callbackTypeDiggBuryChange, this.v);
    }

    public final void onResume() {
        int v4 = R.color.ly;
        int v3 = R.color.gq;
        super.onResume();
        boolean v0 = this.u;
        AppData.getInstance();
        if(v0 != AppData.isNightMode()) {
            AppData.getInstance();
            this.u = AppData.isNightMode();
            if(this.a != null) {
                this.a.setAdapter(this.e);
            }

            if(this.n != null) {
                this.n.setBackgroundColor(this.getResources().getColor(com.ss.android.article.browser.R.color.ssxinmian3));
            }

            if(this.l != null) {
                this.l.init();
            }

            if(this.b == null) {
                return;
            }

            this.d.setBackgroundColor(this.getResources().getColor(com.ss.android.article.browser.R.color.ssxinmian4));
            ((TextView)this.d.findViewById(com.ss.android.article.browser.R.id.ss_retry)).setTextColor(this.getResources().getColor(v4));
            ((TextView) this.d.findViewById(com.ss.android.article.browser.R.id.ss_text)).setTextColor(this.getResources().getColor(v4));
            if(this.b.mFooterTopDivider != null) {
                this.b.mFooterTopDivider.setBackgroundResource(v3);
            }

            if(this.b.mFooterBottomDivider == null) {
                return;
            }

            this.b.mFooterBottomDivider.setBackgroundResource(v3);
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        this.l = ((FoldAnswerListActivity)this.k).a;
        this.l.setOnChildViewClickCallback(((DetailTitleBar.OnChildViewClickCallback)this));
        this.l.setMoreBtnVisibility(false);
        if(android.support.design.a.i()) {
            Activity v0 = this.k;
            o v1 = new o(this);
            ((FoldAnswerListActivity)v0).a.setSearchIconVisibility(0);
            ((FoldAnswerListActivity)v0).a.setSearchClickListener(((View.OnClickListener)v1));
        }

        com.ss.android.article.base.feature.detail2.config.a.b(this.b.mFooterContent);
        this.t = new p(this);
        CallbackCenter.addCallback(BaseAppData.callbackTypeDeleteAnswer, this.t);
        CallbackCenter.addCallback(BaseAppData.callbackTypeFontSizeChange, this.w);
        CallbackCenter.addCallback(BaseAppData.callbackTypeDiggBuryChange, this.v);
        AppData.getInstance();
        this.u = AppData.isNightMode();
    }

    @Override
    public void f(@NonNull Object o) {

    }
}

